import sys

from PySide6.QtWidgets import QApplication

from common.player.reference import Player
from game.save_interface import game_load
from gui.widgets_map import open_window, load_widget
from utils.db import DBSession
from utils.load_assets import load_assets


def game_start(win_name):
    # 没做什么 目的是让DB在程序开始加载资源
    print(f'资源加载完毕, 数据库地址: {id(DBSession)}')
    load_assets()

    if not (player := game_load('aaa')):
        player = Player('aaa')

    app = QApplication(sys.argv)

    load_widget()
    open_window(win_name, player)

    sys.exit(app.exec())


if __name__ == '__main__':
    game_start('main')
